Repository navigation
Conversation
…he initial location
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Now and then a reflowable EPUB in paginated mode opens on the first page of the right resource instead of at the
initialLocation, and the navigator reportsprogression: 0.spreadDidLoad()scrolls after a fixed 0.2 s, butsnapOffset()divides byviewportWidth, which stays0until theResizeObserverframe has run. When that frame is late, the offset isNaNand the page doesn't move.Fixes #946
Change
snapOffset()falls back towindow.innerWidthwhileviewportWidthis still0. That is the valueonViewportWidthChanged()stores anyway.scrollToPosition(),scrollToId()andscrollToLocator()all snap through it.make scripts.Review notes
viewportWidthis non-zero and used as before.spreadDidLoad()(and its TODO) is left as is. Waiting for the firstResizeObserverpass would be the more thorough fix. I kept this PR minimal, but I'm happy to look into that if you prefer.Verification
make scriptspasses ondevelop(format, lint, typecheck, 139 Jest tests, bundle) with Node 24. Onlyreadium-reflowable.jsandreadium-fixed.jschanged.snapOffset(),scrollToPosition()andspreadDidLoad()are the same as ondevelop. I tested the same change there, with the bundle rebuilt, on an iOS 27.2 simulator (iPhone 17 Pro). Each run was a fresh install, opening a locator atprogression: 0.504in an 8-page resource, with the 0.2 s changed to0to force the race:Not covered
utils.jsis plain JavaScript with side effects at load, and the Jest setup only transforms.ts. TestingsnapOffset()would need it moved to a TypeScript module, which seemed out of scope.window.innerWidththe observer would have stored, so those paths should behave as before once measured.